#include <iostream>
#include <string>
#include <map>
   
using namespace std;

int main()
{   
	map<int, map<string, int> > info;
	int n;

	cin >> n;
	for(int i = 0; i < n; i++) {
		int class_id;
		string name;

		cin >> class_id >> name; 
		info[class_id][name]++;
	}

	for(map<int, map<string, int> >::iterator it1 = info.begin(); it1 != info.end(); it1++) {
		for(map<string, int>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); it2++) {
			cout << "There are " << it2->second << " people named " << it2->first << " in class" << it1->first << endl;
		}
	}

	return 0; 
}